using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace HostMonitor
{
    public partial class EditHostFrm : Form
    {
        private HostsData.HostsRow _row;

        protected EditHostFrm()
        {
            InitializeComponent();
        }

        protected void RefreshData()
        {
            cbGroup.DataSource = _row.Table.DataSet;
            cbGroup.DisplayMember = "Groups.GroupName";

            tbName.Text = _row.HostName;
            tbDesc.Text = _row.Description;
            cbGroup.Text = _row.Group;
            cbActive.Checked = _row.Active;
        }

        static public void OpenDialog(HostsData.HostsRow row)
        {
            EditHostFrm frm = new EditHostFrm();
            frm._row = row;
            frm.RefreshData();
            frm.ShowDialog();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            _row.HostName = tbName.Text;
            _row.Group = cbGroup.Text;
            _row.Description = tbDesc.Text;
            _row.Active = cbActive.Checked;
            Close();
        }
    }
}